home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok70.lha
/
PL0
/
txt
/
PL0Generator.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
1KB
|
65 lines
(*************************************************************************
:Program. PL0Generator.mod
:Contents. Code-Generator for PL0-Complier
:Author. N. With, ported to Oberon by hartmut Goebel
:Language. Oberon
:Translator. Amiga Oberon
:Imports. TextWindows (hartmut Goebel)
*************************************************************************)
MODULE PL0Generator;
IMPORT
int: PL0Interpreter, NoGuru,
tw: TextWindows;
VAR
L: INTEGER;
win: tw.TxtWinPtr;
PROCEDURE InitGenerator*;
BEGIN
L := 0;
tw.ClrHome(win);
END InitGenerator;
PROCEDURE Label*(): INTEGER;
BEGIN
RETURN L;
END Label;
PROCEDURE Gen*(f: SHORTINT; l,a: INTEGER);
BEGIN
IF L >= int.maxadr THEN HALT(10); END;
int.code[L].f := f; int.code[L].l := l; int.code[L].a := a;
tw.WriteInt(win,L,4);
tw.WriteString(win,int.mnemonic[f]);
tw.WriteInt(win,l,4);
tw.WriteInt(win,a,4);
tw.WriteLn(win);
INC(L);
END Gen;
PROCEDURE fixup*(x:INTEGER);
BEGIN
int.code[x].a := L;
tw.WriteString(win,"fixup at");
tw.WriteInt(win,x,4); tw.WriteLn(win);
END fixup;
BEGIN
win := tw.OpenTextWin("CODE",204,110,204,140);
IF (win=NIL) THEN HALT(20) END;
CLOSE
IF win # NIL THEN tw.CloseTextWin(win); END;
END PL0Generator.